package com.ivt.dao;

import javax.persistence.QueryHint;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;

import com.ivt.model.Role;

public interface RoleDao extends JpaRepository<Role, Long> {

	@QueryHints({ @QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true") })
	@Query(value = "SELECT  count(r) FROM  Role r where  r.roleName = ?1")
	long existsByName(String roleName);

	@QueryHints({ @QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true") })
	@Query(value = "SELECT  count(r) FROM  Role r where r.roleName = ?1 and r.roleId = ?2")
	long existsByNameAndId(String roleName, Long roleId);

}
